package com.tengju.support.domain.model.message;


import com.tengju.support.domain.shared.DomainException;
import com.tengju.support.domain.shared.DomainExceptionCode;

public class BatchIdFactory {

    public static BatchId create(String batchIdStr) {

        String[] val = batchIdStr.split("_");
        if (val.length != 3) {
            throw DomainException.error(DomainExceptionCode.INVALID_DATA,"batch格式错误");
        }

        TaskId taskId = new TaskId(Long.parseLong(val[0]));
        MessageType messageType = MessageType.fromVal(Integer.parseInt(val[1]));

        return new BatchId(taskId,messageType,val[2]);



    }

}
